# 导包
import requests

# 发送百度首页接口请求
response = requests.get(url="http://www.baidu.com")
# 打印响应数据
# 获取经过Requests处理之后的URL:response.url
print("URL: ", response.url)
# 获取服务器返回的响应状态码:response.status_code
print("响应状态码:", response.status_code)
# 获取响应头:response.headers
print("响应头: ", response.headers)
# 获取Cookie:response.cookies
print("Cookie: ", response.cookies)
# 获取编码:response.encoding
print("编码: ", response.encoding)
# 获取文本格式响应体:response.text
print("文本格式响应体: ", response.text)
# 获取Json格式响应体:response.json()
# print("Json格式响应体: ",response.json()) # 会报错，因为返回的不是json数据，而是html数据
# - 获取字节码形式响应体:response.content
print("字节码响应体：", response.content)
# 解决乱码
print("解决乱码：", response.content.decode("utf-8"))
